//@ts-ignore
import request from '@/utils/request';
//@ts-ignore
import type {
    LoginFormData,
    ResponseData,
    RegisterFormData,
    userQueryRequestData,
    userUpdateRequestData,
    userUpdatePasswordRequestData,
    AddFormData
} from '@/api/user/type';

/**
 * 用户接口集合
 */
enum API {
    LOGIN_URL = '/user/login',
    REGISTER_URL = '/user/register',
    USERLIST_URL = '/user/list/page',
    DELTTEUSER_URL = '/user/delete',
    UPDATEUSER_URL = '/user/update',
    USERINFO_URL = '/user/get',
    USERPASSWORD_URL = '/user/password',
    ADDUSER_URL = '/user/add',
}

export const reqLogin = (data: LoginFormData) =>
    request.post<any, ResponseData>(API.LOGIN_URL, data)

export const reqRegister = (data: RegisterFormData) =>
    request.post<any, ResponseData>(API.REGISTER_URL, data)

export const reqUserList = (data: userQueryRequestData) =>
    request.post<any, ResponseData>(API.USERLIST_URL, data)

export const reqDeleteUser = (data: {id:Number}) =>
    request.post<any, ResponseData>(API.DELTTEUSER_URL, data)

export const reqUpdateUser = (data: userUpdateRequestData) =>
    request.post<any, ResponseData>(API.UPDATEUSER_URL, data)

export const reqUserInfo = (id: Number) =>
    request.get<any, ResponseData>(API.USERINFO_URL+`/?id=${id}`,)

export const reqUpdatePasswordUser = (data: userUpdatePasswordRequestData) =>
    request.post<any, ResponseData>(API.USERPASSWORD_URL, data)

export const reqAddUser = (data: AddFormData) =>
    request.post<any, ResponseData>(API.ADDUSER_URL, data)


